<?php
/**
 * Created by PhpStorm.
 * User: Celebration-Grey
 * Date: 2017/5/8
 * Time: 15:58
 */

namespace App\Http\Controllers\Admin;


use App\Http\Classes\Level;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Http\Classes\Log;

class LevelController extends Controller
{
    public function getLevels(Request $request){
        try{
            $data = $request->all();
            $data = Level::getLevels($data);
            if($data){
                return $this->response(200,'获取成功！',$data);
            }
            else{
                return $this->response(304,'获取失败！',null);
            }
        }
        catch (\Exception $exception){
            Log::adminError(__FUNCTION__,$exception->getCode(),$exception->getMessage(),$exception->getFile(),$exception->getLine(), session('admin.admin_id') ? session('admin.admin_id') : 0);
            return $this->response(500,"系统内部错误！".$exception->getMessage(),null);
        }
    }

    private function response($status,$message,$data){
        $response = [];
        $response['status'] = $status;
        $response['message'] = $message;
        $response['data'] = $data;
        return response()->json($response);
    }
}